﻿using System;

namespace SacNetUG.Models
{
    public partial class TeamMember
    {
        //Not sure about this overload - the usage of this method changes dramatically based on 
        //whether the record has been persisted to the database or not
        //public string GetPersistedFileName(string fileName)
        //{
        //    return string.Format("{0}.{1}", User.UserId, GetFileExtension(fileName));
            
        //}
        public string GetPersistedFileName()
        {
            //if (this.ImageFileName == null)
            //{
            //    return "";
            //}
            //return string.Format("{0}.{1}", User.UserId, GetFileExtension(this.ImageFileName));
            return "";

        }
        public static string GetPersistedFileName(string fileName, int userId)
        {
            return string.Format("{0}.{1}", userId, GetFileExtension(fileName));
        }

        private static string GetFileExtension(string fileName)
        {
            int found = fileName.LastIndexOf(".");
            if (found > -1)
                return fileName.Substring(found + 1);
            else
                return "";
        }
    }
}
